package com.example.jeong.yuejian10.Activity;

import android.app.Activity;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;

import com.example.jeong.yuejian10.Adapter.ClubCourseAdapter;
import com.example.jeong.yuejian10.Bean.CourseBean;
import com.example.jeong.yuejian10.Listener.RetrofitListener;
import com.example.jeong.yuejian10.Model.ClubModel;
import com.example.jeong.yuejian10.R;

import java.util.List;

//俱乐部详情内的精选课程页
public class ClubCourseActivity extends Activity implements View.OnClickListener,RetrofitListener<List<CourseBean>> {
private ImageView left;
private RecyclerView recyclerView;
private ClubCourseAdapter adapter;

@Override
public void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_club_course);
        initView();
        initEvent();
    getClubcourselist();

        }

private void initView() {
        recyclerView = (RecyclerView) findViewById(R.id.club_course);
        recyclerView.setLayoutManager(new LinearLayoutManager(this));//设置布局
        left = (ImageView) findViewById(R.id.left);

        }

     private void initEvent() {
        //返回上一页
        left.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
               finish();}
        });
 }
    void getClubcourselist(){
        Bundle bundle = this.getIntent().getExtras();
        int c_id = bundle.getInt("c_id");
        ClubModel clubModel=new ClubModel();
        clubModel.getClubcourselist(c_id,this);
        }

    @Override
    public void onSuccess(List<CourseBean> courseBeen){
        adapter = new ClubCourseAdapter(ClubCourseActivity.this,courseBeen);
        recyclerView.setAdapter(adapter);
    }

@Override
public void onFail() {
        //showToast("网络发生错误");
        }
@Override
public void onClick(View view) {

        }
}
